package com.dyao.limit.example.controller;


import com.augrain.microframework.limit.annotation.RateLimiter;
import com.augrain.microframework.limit.annotation.RateRule;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
public class LimitController {

    @RateLimiter(prefix = "test", rules = {
            @RateRule(limit = 1, timeDuration = 1, timeUnit = TimeUnit.SECONDS),
            @RateRule(limit = 10, timeDuration = 1, timeUnit = TimeUnit.MINUTES),
    })
    @GetMapping("/limit/multi")
    public String multiLimit() {
        return "success";
    }

    @RateLimiter(prefix = "test", rules = {
            @RateRule(limit = 10, timeDuration = 1, timeUnit = TimeUnit.MINUTES)
    })
    @GetMapping("/limit/single")
    public String singleLimit() {
        return "success";
    }
}
